package com.glorysoft.tonglingxjpda.base

import android.util.Log
import com.glorysoft.tonglingxjpda.entity.net.BaseRequestBean
import com.glorysoft.tonglingxjpda.entity.net.HeaderBean
import com.glorysoft.tonglingxjpda.entity.net.NetRequestBean
import com.glorysoft.tonglingxjpda.utils.TrimUtils
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils
import org.apache.commons.lang3.StringEscapeUtils
import java.util.*

/**
 * @author HX
 * @date 2021/4/21
 * @desc
 */
open class BaseRepository {
    protected fun getInJsonData(map: JsonObject,messageName : String): Map<String,String> {
        val format: NetRequestBean<*> = NetRequestBean<Any?>()
        format.body =map
        format.header = HeaderBean(messageName)
//        val message: BaseRequestBean<*> = BaseRequestBean<Any?>()
//        message.request = format
        val map: MutableMap<String, String> = HashMap()
        map["senderId"] = "EAP2MESSender"
        val unescapeJson = Gson().toJson(format)
//        val replace = unescapeJson.replace("\'","\\\'")
        map["requestMessage"] = TrimUtils.trimnull(unescapeJson)
//        map["timeOut"] = "5000"
        Log.e("请求JSON", "getInJsonData: ${TrimUtils.trimnull(unescapeJson)}")
        FreeApi_LogUtils.saveErrorMessages(unescapeJson,"请求json")
        return map
    }
}